import 'dart:math';
import 'dart:typed_data';

import 'package:hotpot/extensions/data.dart';

import '../models/res_partner.dart';

abstract class UserUtils {

  static late ResPartner _partner;

  static ResPartner get partner => _partner;

  static int get partnerId => _partner.id!;

  static String get companyName => _partner.companyId?[1] ?? '';

  static Uint8List? get companyImg => _partner.image128.bytes;

  static void init(ResPartner partner) {
    _partner = partner;
  }
  
  static String createUnique() {
    var time = DateTime.now().millisecondsSinceEpoch;
    var time36 = time.toRadixString(36);
    var random = Random();
    String random36 = '';
    for (var i = 0; i < 5; i++) {
      random36 += random.nextInt(16).toRadixString(36);
    }
    return '042$time36-$random36';
  }

}